home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Mag HDD Backup
/
Amiga Mag HDD Backup.zip
/
Amiga Mag HDD Backup
/
Alexander.img.bin
/
Alexander.img
/
9.12
/
Frawley⁄Digital FX14
/
DISFX.ColorCorrect101.ascii
< prev
next >
Wrap
Text File
|
1983-05-04
|
14KB
|
168 lines
digital image special fx
COLOR CORRECTION 101
Exploring 1-To-1 Pixel Transformations
by William Frawley
Since coverage of basic video color correction is scarce among monthly computer-oriented
periodicals, especially for Amiga users, it's time we learn what all those Balancing functions like
Bright, Contrast and Gamma actually do and what related terms such as Dynamic Range,
Posterization and Histogram really mean. Alas, welcome to Color Correction 101. Here we'll
uncover the theory behind 1-To-1 pixel transformations and illustrate their effect on a sample
image. We'll also see how most of the digital image manipulation tools used to perform these
functions closely resemble in operation many photographic darkroom techniques.
From print media via desktop publishing to video production, fine tuning the color content
of a photograph or a video signal is a crucial step taken to ensure the most accurate color
reproduction possible for the viewer's digestion, and ultimately, their perception. For example, in
video production, consider the case where two different scenes are shot with two different types of
video camcorders. In the final edit, color correction of the two disparate video signals is necessary
for an inconspicuous, seamless transition between the two scenes. This is an example of a more
advanced application of color transformation. However, as we shall see, pixel transformations can
be as simple as adding contrast or brightness, producing a negative or even reducing the amount
of colors in an image, a process called quantization or posterization. But before we demystify
these processes, here's what you'll need to get started.
Prerequisites
Okay, if you're reading this column, odds are you have some kind of image processing
software. For this series, we'll generally be using ADPro for most of the basic operations and
ImageFX for more of the special functions, but every concept and even most functions and
operators easily apply to other packages as well -- like OpalPaint and ImageMaster R/T. We will
try to occasionally enlist these others when we examine next month some of the more advanced
operations exclusive to a particular program. Until then, all interested graphics users should
follow along because this article deals with the general theory of pixel transformations -- the
underlying principles of enhancing an image through color correction.
RGB and HSV Color Systems
Before we begin, perhaps I should point out that our dealings with color and methods of
correction will be confined to digital video and the world of pixels. At this point, I would hope
that you already know what pixels are. If not, remember that pixel is an abbreviation for picture
element, the individual `dots' or units that constitute a bitmap image.
When dealing with video or images in the digital realm, recall that the systems used for
color manipulation can consist of either the RGB (Red Green Blue), HSV (Hue Saturation
Value) or in more high-end broadcast situations, the YUV (Luminance Y/R-Y/B-Y) color system.
As the space allotted here will not allow for a full explanation of the complexity of video signals,
suffice it to say that these color models were designed with respect to how colors are actually
reproduced and what devices they are output to. That is, the color video signal is output to a
monitor, which consists of separate red, green and blue color guns. Therefore, the most
appropriate `color space' to work in would be the RGB system or the more general and flexible
HSV color system. Obviously, since we are dealing with light beams as the final output, both
systems mentioned subscribe to the additive theory of color reproduction, in contrast to the
CMYK system of color separation for print media, whose output is based upon the subtractive
theory of color. Consequently, the mechanics of the output process dictate the best method or
system to deal with the individual components of color, be it light or the more tangible pigments.
With that exposition in mind, let's now expose the nature of 1-to-1 pixel transformations.
1-To-1 Pixel Transformations
Simply put, these types of 1-to-1 transformations are such that the value of a pixel's output
is strictly a function of the input pixel's value. In other words, the new value depends only on the
original value. Written in mathematical notation, the relationship looks like this: y=f(x). On the
contrary, there exist certain processes like convolution and dithering which are not simple 1-to1
relationships but rely on a matrix of pixels. Convolutions base their output on a neighborhood of
surrounding input pixels, and similarly, dithering also depends on values of nearby pixels and
their position in the bitmap plane.
Because of the simplicity of their nature, we can easily show these 1-to-1 transforms graphed
two-dimensionally, where the horizontal axis represents discrete input values from 0-255 and the
vertical axis represents the discrete output values from 0-255. Despite the fact that our sample
image is color, just think of the function graphs as representing the input-output relationships of
a monochrome grayscale image, or just one component of the RGB combination. Let's now take a
look at a variety of 1-to-1 transformation algorithms and their effect on our sample image.
Example Transformations
NULL: For completeness, the simplest transform is obviously a null transform, where the
output is exactly equal to the input. In mathematical notation we write, f(x)=x. In this case, noth-
ing changes. The new pixel has the same value as the old pixel. Not very exciting, but it demon-
strates that even the simplest of functions provide a basic understanding of important relation-
ships between input and output values. Refer to Figure 1A which shows the graphical repre-
sentation of the Null transformation. Figure 1B illustrates a good example image to begin our
demonstration because it provides an even distribution bandwidth of luminance values to work
with, as shown in a histogram for this image (see next month's article for a discussion on the im-
portance of histograms).
NEGATIVE: Also known as Photo-Inversion, this transform reverses the output luminance
values, similar to a photographic negative. Imagine a horizontal line extending midway from the
vertical axis. Using this imaginary line as an axis of symmetry, flip the Null function about this
axis and you end up with the Negative function. Essentially, any dark pixels become bright and
any bright pixels become dark. Median value pixels don't change that much, and specifically, if a
pixel had the luminance value of 128 to begin with, it would remain 128 after the transformation.
This value acts as the pivot point for the function inversion, remembering that there are 256 pos-
sible luminance values for 8-bit images or for each RGB component of 24-bit images. .This func-
tion could be written as, f(x)=256-x. See Figure 2A for a graphical representation of the trans-
formation. Figure 2B shows the effect of using ADPro's Negative operator on our sample image.
BRIGHTNESS: This type of adjustment or transformation affects the brightness of an im-
age. It does so by uniformly shifting the color map upwards or downwards by a certain Offset
value. Therefore, all input values get shifted by the exact same amount, no matter where they lie
on the horizontal axis (input value axis). Notice that any range of input intensities also produces
the exact range of output intensities, only shifted upwards or downwards by the Offset value. The
slope of the curve remains the same. This transform can be written as f(x)=Offset+x. The in-
creased brightness function is illustrated in Figure 3A. The result shows that all color values get
boosted by some Offset amount, thus making the image brighter. The disadvantage of this type of
transform is demonstrated in the extreme luminance values. Note that there are no longer any
extreme dark values, and any lighter values above a certain point get clipped, or all receive the
same maximum value of 255. This eliminates any detail in the lighter portion of the image. Just
the opposite occurs with decreased brightness. Figures 3B and 3C show the result of increased
and decreased brightness, respectively. Note that the function is still linear and contains the same
slope as before which remains constant. Some of these factors will change in the following trans-
forms.
CONTRAST: This popular 1-to-1 transformation is similar in some respects to both the
Negative and the Brightness adjustments. Like the Negative transform, this color map is pivoted
about the center point, thus changing the slope of the function. Unlike the Negative transform
however, the slope still remains positive so there is still a `normal' relationship between the input
values and the output values. A larger slope means increased contrast, and a more horizontal
slope represents decreased contrast. Additionally, like the Brightness transform, adjusting the con-
trast or slope of the `curve' also produces undesirable clipping at the extreme ends of the input
intensities. This transform's strength, however, lies in the fact that for any given range of input
values, except for the clipped regions, the corresponding range of output values have been ex-
panded, thus adding increased detail in those areas. Figure 4A shows this relationship with the
shaded areas representing arbitrary value ranges selected for examination. The slightly more com-
plex, but still linear, mathematical formula can be written as f(x)=0 when x<=low,
f(x)=(x-low)/(high-low) when low<x<high, and f(x)=255 when x>=high. The effects of in-
creased and decreased contrast are illustrated in Figures 4B and 4C, respectively.
GAMMA: Containing characteristics of both Brightness and Contrast adjustments, this
transform adjusts the overall brightness of an image at the same time affecting the contrast in a
non-linear fashion. It is non-linear because the slope of the curve, and here it is actually curvilin-
ear, is constantly changing. Unlike the Brightness function however, the advantage here is that
because of the non-linear nature of the curve, the extreme highs and lows avoid clipping, thus
preserving detail in these regions. Additionally, because there is a perpetually changing slope, in-
put values lying in a certain range produce either expanded or contracted output values, depend-
ing upon what part of the curve is considered. Consequently, different regions of the curve pro-
duce either increased or decreased contrast. Only at one point, usually the center, does the slope
remain equal to the original. This function is written as f(x)=x^gamma. When gamma<1, the curve
bows upward, producing increased brightness. When gamma>1, the curve bows downward, de-
creasing the overall brightness of the image. A gamma value equal to 1 produces a null transform.
Figure 5A illustrates a gamma correction transform with a factor less than 1, thus increasing the
overall brightness of the input signal.
The nature of the Gamma transform closely parallels certain real-world conditions such as
the brightness control response of CRT's and certain variations in darkroom exposure param-
eters. This form of adjustment curve takes into account these types of non-linear output responses
to linear input ranges. For example, output devices like your monitor are usually considered to
have a gamma factor of 2.2 producing a downward-bowed curve. This results in the darkening of
the video output. To compensate for this darker, non-linear response, we brighten the image by
applying a reciprocal gamma curve to the output signal. In this case, we would use a gamma cor-
rection curve with a gamma factor of .45, the reciprocal of 2.2. This would then bring the dis-
played output within normal viewing parameters. Figures 5B and 5C show the effects of both
increased and decreased gamma corrections, respectively.
POSTERIZATION: Also known as and a more accurately termed transform called quan-
tization, this adjustment has the effect of reducing the output to a distinct number of values by
`slicing' the input intensities into a discrete number of ranges. Each member of a range is then
assigned the same output intensity. This creates a stair-step transform function curve as shown in
Figure 6A. Creating a monochrome image is an extreme case of quantization, resulting in all
input values being mapped to a luminosity of either 0 or 255. In this case, the function is written
as f(x)=0 when 0<=x<=128(?) and f(x)=255 when 128(?)<=x<=255. In this case, the value of
128 is arbitrary. Any cut-off point could be chosen. However, most image processors with a pos-
terization operator allow you to choose the number or complexity of output levels. The example
in Figure 6B was created with ImageFX's Posterize... tool located in the Color Effects menu
where a level of 5 out of 16 was used. In a sense, every time you render a full-color image to a
native Amiga display format, a reduced output value color map in the same vein as a posteriza-
tion transform is created for the graphics hardware to display the image. With normal rendering
though, the render algorithm picks the optimum colors for the best possible display output.
Next Time
Well, that about covers the basic color transformations. Hopefully, now that you understand
the operation of them, you'll be apt to use them more frequently. From enhancing poorly scanned
clipart to spicing up your latest video work with special effects, 1-to-1 pixel transformations can
provide countless ways to easily but powerfully process images. Believe me, we've just scratched
the surface of color transformations. Next month, we'll continue our look at some custom 1-to-1
transformations, specialized transformation operators like ADPro's Intensity Range, including the
use and meaning of histograms, and much more. Until then, experiment. It's a blast!